package com.goldsprite.gameframeworks.simplephys.collis;

import com.badlogic.gdx.utils.Pool;
import com.goldsprite.gameframeworks.utils.math.Vector2;

public class CollisionResult implements Pool.Poolable {
	/** 是否发生碰撞 */
	public boolean collided;

	/** 碰撞法线，指向让物体A分离的方向, 即碰撞边垂向且朝外的方向 */
	public final Vector2 normal = new Vector2();

	/** 穿透深度, 如果嵌入则该值为>0的数 */
	public float depth;
	public float t;

	public boolean isDcd;

	public CollisionResult() {
		reset();
	}

	/** 重置结果 */
	@Override
	public void reset() {
		collided = false;
		normal.set(0, 0);
		depth = 0;
		t = 0;
		isDcd = false;
	}

	@Override
	public String toString() {
		if (!collided) {
			return "CollisionResult{no collision}";
		}
		return String.format("CollisionResult{normal=%s, depth=%.3f}", normal, depth);
	}
}
